/**
 * Created by WYH on 17/4/25.
 */
angular.module('rentVerify', []).component(
    'rentVerify',
    {
        templateUrl: 'component/rent/rentVerify/rent_verify.template.html',
        controller: ['$scope', 'Api', 'RentPaymentModel','Alert', function ($scope, Api,RentPaymentModel,Alert) {



            $scope.submitRentVerify = submitRentVerify;

            function submitRentVerify(bankSerialNum, amount) {
                var rentPayment = $scope.$parent.rentPayment || new RentPaymentModel();
                var mismatch = !!rentPayment.bankSerialNum && !!rentPayment.amount && rentPayment.bankSerialNum == bankSerialNum && rentPayment.amount == amount;
                if (rentPayment.bankSerialNum != bankSerialNum || rentPayment.amount != amount) {
                    Alert.alertBox('输入的银行流水号，缴费金额不匹配');
                } else {
                    Api.checkRentPayment(rentPayment.id, mismatch, bankSerialNum, amount, function (result) {
                        Alert.alertBox('核实成功',function () {
                           return window.location.reload();
                        });
                    })
                }
            }
        }]
    }
);